/** 
 * File-Name:CommonAction.java
 *
 * Created on 2010-12-22 下午02:18:38
 * 
 * @author: Neo (neolimeng@gmail.com)
 * Software Engineering Institute, Peking University, China
 * 
 * Copyright (c) 2009, Peking University
 * 
 *
 */
package xiaoyou.neoutil;

import org.apache.struts2.ServletActionContext;

import xiaoyou.service.ArticleRepository;
import xiaoyou.service.FundRepository;
import xiaoyou.service.ProjectRepository;

import com.opensymphony.xwork2.ActionSupport;

/**
 * Description:Base Action class for the Tutorial package.
 * 
 * @author: Neo (neolimeng@gmail.com) Software Engineering Institute, Peking
 *          University, China
 * @version 1.0 2010-12-22 下午02:18:38
 */
public class CommonAction extends ActionSupport {
	public static final String RELOGIN = "relogin";

	protected Object getSessionObject(String key) {
		return ServletActionContext.getRequest().getSession().getAttribute(key);
	}

	protected void setSessionObject(String key, Object value) {
		ServletActionContext.getRequest().getSession().setAttribute(key, value);
	}

	protected String getRequestParameter(String key) {
		return ServletActionContext.getRequest().getParameter(key);
	}

	private static FundRepository fundRepository;

	protected FundRepository getFundRepository() {
		if (fundRepository == null) {
			fundRepository = new FundRepository();
		}
		return fundRepository;
	}
	
	private static ProjectRepository projectRepository;

	protected ProjectRepository getProjectRepository() {
		if (projectRepository == null) {
			projectRepository = new ProjectRepository();
		}
		return projectRepository;
	}
	
	private static ArticleRepository articleRepository;

	protected ArticleRepository getArticleRepository() {
		if (articleRepository == null) {
			articleRepository = new ArticleRepository();
		}
		return articleRepository;
	}
}
